package school.xauat.inscription_sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import school.xauat.inscription_sys.mapper.CharactersMapper;
import school.xauat.inscription_sys.pojo.Characters;
import school.xauat.inscription_sys.service.CharactersService;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zsy
 * @since 2022-04-26
 */
@Service
public class CharactersServiceImpl extends ServiceImpl<CharactersMapper, Characters> implements CharactersService {

    @Autowired
    CharactersMapper charactersMapper;

    @Override
    public int getByName(String name) {
        Characters ch = charactersMapper.selectOne(new QueryWrapper<Characters>().eq("name", name));
        if (ch == null) {
            log.error(String.format("charactersMapper.selectOne return nil,name:%s", name));
            return -1;
        }
        return ch.getId();
    }
}
